﻿using AntdUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace TCOChart
{
    public partial class FormRadioButton : Form
    {
        private FormFloatButton floatButtonForm = null;
        public FormRadioButton()
        {
            InitializeComponent();


        }

        private void checkbox1_CheckedChanged(object sender, AntdUI.BoolEventArgs e)
        {
            checkbox2.Checked = e.Value;
            checkbox3.Checked = e.Value;
        }

        private void button_floatButton_Click(object sender, EventArgs e)
        {
            LoadFloatButton();
        }

        private void LoadFloatButton()
        {
            if (floatButtonForm == null)
            {
                floatButtonForm = FloatButton.open(new FloatButton.Config(this, new FloatButton.ConfigBtn[] {
                    new FloatButton.ConfigBtn("button1", "", true)
                    {
                        // isSvg设置为true，text参数会赋值给IconSvg，否则赋值给Text,所以需要单独设置Text
                        Text = "SVG Picture",
                        IconSvg = "ExclamationCircleOutlined",
                        Tooltip = "SVG Button",
                    },
                     new FloatButton.ConfigBtn("button2")
                    {
                         Text = "Btn",
                         Tooltip = "Resource Picture Button",

                     },
                }, button =>
                {
                    //回调事件
                    AntdUI.Message.info(this, "Text:" + button.Text + ", Name:" + button.Name, autoClose: 3);
                })
                // 浮动全局配置
                {
                    //字体
                    Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point),
                    //附着控件
                    Control = null,
                    // 按钮显示位置：右下方向
                    Align = TAlign.RB,
                    //是否垂直方向
                    Vertical = true,
                    //是否置顶
                    TopMost = false,
                    //尺寸大小
                    Size = 30,
                    //相对于Align位置X轴偏移
                    MarginX = 20,
                    //相对于Align位置Y轴偏移
                    MarginY = 20,
                    //按钮间距
                    Gap = 20,

                });
            }
        }

        public void CloseFloatButtonForm()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(CloseFloatButtonForm));
            }
            else
            {
                // Ensure that floatButtonForm is not null before attempting to close it
                if (floatButtonForm != null)
                {
                    floatButtonForm.Close();
                    floatButtonForm.Dispose();
                    floatButtonForm = null;
                }
            }
        }

        private void button_floatButtonClose_Click(object sender, EventArgs e)
        {
            CloseFloatButtonForm();
        }
    }
}
